﻿using MediatR;
using T_Material.API.Application.Commands.PurchaseCommand;
using T_Material.Domain;
using T_Material.Infrastructure.Interface;

namespace T_Material.API.Application.CommandHandlers.PurchaseHandler
{
    public class PurchaseUpdateStateCommandHandler : IRequestHandler<PurchaseUpdateState, int>
    {
        private readonly IPurchaseRepository purchaseRepository;
        public PurchaseUpdateStateCommandHandler(IPurchaseRepository purchaseRepository)
        {
            this.purchaseRepository = purchaseRepository;
        }
        public async Task<int> Handle(PurchaseUpdateState request, CancellationToken cancellationToken)
        {
            var info =await purchaseRepository.GetModelAs(request.Id);
            info.AuditState = 1;
            info.ApprovedBy = null;
            //info.UpdateBy = "李四";
            //info.UpdateDate = DateTime.Now;
            //info.IsDel = false;
            var res = await purchaseRepository.Update(info);
            return res;
        }
    }
}
